在C或C++中如何使用PI(π)值 | 您所在的位置:网站首页 › 宏定义define pi 31416中定义pi › 在C或C++中如何使用PI(π)值 |
#include
#define PI acos(-1)
主要是利用利用数学函数中的反三角函数,但是要注意一定引入math包 arccos ( − 1 ) = π \arccos(-1)=\pi arccos(−1)=π 完整示例: //#define LOCAL #include #include #include using namespace std; #define PI acos(-1) int main() { printf("%.30lf\n",PI); return 0; }结果: 位数一般够了。 |
CopyRight 2018-2019 实验室设备网 版权所有 |